 Imports MySql.Data.MySqlClient 
 Imports System.Data.OleDb
Imports System.Data.SqlClient
 Imports System .Data .SqlServerCe 
 Imports System.Data.OracleClient 
Imports System.Data
Imports DTO
Public Class GIAOVIENTHEDao
Inherits AbstractDao
 #Region "New" 
 Public Sub New(ByVal connection As KetNoiDto)
 MyBase.New(connection)
 End Sub
 Public Sub New( ByVal IDGIAOVIENTHE As System.Int32, ByVal connection As KetNoiDto)
 MyBase.New("GIAOVIENTHE", "select * from GIAOVIENTHE where IDGIAOVIENTHE=" & IDGIAOVIENTHE & "", connection)
 End Sub
 #End Region 
 Public Sub Them(ByVal Dto As GIAOVIENTHEDto)
 Dim strsql As String
 strsql = "Insert into GIAOVIENTHE(IDGIAOVIEN,IDLOPHOC,NGAY,TRANGTHAI,GHICHU) values (?,?,?,?,?)
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 Dim cmd As New OleDbCommand(strsql, Ket_noi_access)
cmd.Parameters.Add("@IDGIAOVIEN", OleDbType.Integer)
cmd.Parameters.Add("@IDLOPHOC", OleDbType.Integer)
cmd.Parameters.Add("@NGAY", OleDbType.Date)
cmd.Parameters.Add("@TRANGTHAI", OleDbType.Integer)
cmd.Parameters.Add("@GHICHU", OleDbType.VarWChar)
cmd.Parameters("@IDGIAOVIEN").Value = Dto.IDGIAOVIEN
cmd.Parameters("@IDLOPHOC").Value = Dto.IDLOPHOC
cmd.Parameters("@NGAY").Value = Dto.NGAY
cmd.Parameters("@TRANGTHAI").Value = Dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = Dto.GHICHU
 cmd.ExecuteNonQuery()
 strsql = "Select @@IDENTITY"
 cmd = New OleDbCommand(strsql, Ket_noi_access)
 Dto.IDGIAOVIENTHE = cmd.ExecuteScalar()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress
 strsql = "Insert into GIAOVIENTHE(IDGIAOVIEN,IDLOPHOC,NGAY,TRANGTHAI,GHICHU) values (@IDGIAOVIEN,@IDLOPHOC,@NGAY,@TRANGTHAI,@GHICHU)
 Dim cmd As New sqlCommand(strsql, Ket_noi_sql)
cmd.Parameters.Add("@IDGIAOVIEN", SqlDbType.Int)
cmd.Parameters.Add("@IDLOPHOC", SqlDbType.Int)
cmd.Parameters.Add("@NGAY", SqlDbType.DateTime)
cmd.Parameters.Add("@TRANGTHAI", SqlDbType.Int)
cmd.Parameters.Add("@GHICHU", SqlDbType.NVarChar)
cmd.Parameters("@IDGIAOVIEN").Value = Dto.IDGIAOVIEN
cmd.Parameters("@IDLOPHOC").Value = Dto.IDLOPHOC
cmd.Parameters("@NGAY").Value = Dto.NGAY
cmd.Parameters("@TRANGTHAI").Value = Dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = Dto.GHICHU
 cmd.ExecuteNonQuery()
 strsql = "Select @@IDENTITY"
 cmd = New sqlCommand(strsql, Ket_noi_sql)
 Dto.IDGIAOVIENTHE = cmd.ExecuteScalar()
 Case Class_KieuDL.SqlCe
 strsql = "Insert into GIAOVIENTHE(IDGIAOVIEN,IDLOPHOC,NGAY,TRANGTHAI,GHICHU) values (@IDGIAOVIEN,@IDLOPHOC,@NGAY,@TRANGTHAI,@GHICHU)
 Dim cmd As New sqlceCommand(strsql, Ket_noi_SqlCe)
cmd.Parameters("@IDGIAOVIEN").Value = Dto.IDGIAOVIEN
cmd.Parameters("@IDLOPHOC").Value = Dto.IDLOPHOC
cmd.Parameters("@NGAY").Value = Dto.NGAY
cmd.Parameters("@TRANGTHAI").Value = Dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = Dto.GHICHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strsql = "Insert into GIAOVIENTHE(IDGIAOVIEN,IDLOPHOC,NGAY,TRANGTHAI,GHICHU) values (@IDGIAOVIEN,@IDLOPHOC,@NGAY,@TRANGTHAI,@GHICHU)
 Dim cmd As New OracleCommand(strsql, Ket_noi_Oracle)
cmd.Parameters("@IDGIAOVIEN").Value = Dto.IDGIAOVIEN
cmd.Parameters("@IDLOPHOC").Value = Dto.IDLOPHOC
cmd.Parameters("@NGAY").Value = Dto.NGAY
cmd.Parameters("@TRANGTHAI").Value = Dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = Dto.GHICHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Mysql
 strsql = "Insert into GIAOVIENTHE(IDGIAOVIEN,IDLOPHOC,NGAY,TRANGTHAI,GHICHU) values (@IDGIAOVIEN,@IDLOPHOC,@NGAY,@TRANGTHAI,@GHICHU)
 Dim cmd As New MySqlCommand(strsql, Ket_noi_MySql)
cmd.Parameters.Add("@IDGIAOVIEN", MySqlDbType.Int32)
cmd.Parameters.Add("@IDLOPHOC", MySqlDbType.Int32)
cmd.Parameters.Add("@NGAY",  MySqlDbType.DateTime)
cmd.Parameters.Add("@TRANGTHAI", MySqlDbType.Int32)
cmd.Parameters.Add("@GHICHU", MySqlDbType.String)
cmd.Parameters("@IDGIAOVIEN").Value = Dto.IDGIAOVIEN
cmd.Parameters("@IDLOPHOC").Value = Dto.IDLOPHOC
cmd.Parameters("@NGAY").Value = Dto.NGAY
cmd.Parameters("@TRANGTHAI").Value = Dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = Dto.GHICHU
 cmd.ExecuteNonQuery()
 End Select
 Ngatketnoi()
 End Sub
 Public Sub Xoa( ByVal IDGIAOVIENTHE As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
strSQL = "Delete From GIAOVIENTHE Where IDGIAOVIENTHE= ? 
Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
cmd.Parameters.Add("@IDGIAOVIENTHE",OleDbType.Integer).Value = IDGIAOVIENTHE
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
strSQL = "Delete From GIAOVIENTHE Where IDGIAOVIENTHE= @IDGIAOVIENTHE
Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
cmd.Parameters.Add("@IDGIAOVIENTHE",SqlDbType.Int).value=IDGIAOVIENTHE
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
strSQL = "Delete From GIAOVIENTHE Where IDGIAOVIENTHE=" & IDGIAOVIENTHE & "
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
strSQL = "Delete From GIAOVIENTHE Where IDGIAOVIENTHE=" & IDGIAOVIENTHE & "
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
strSQL = "Delete From GIAOVIENTHE Where IDGIAOVIENTHE=" & IDGIAOVIENTHE & "
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select
 Ngatketnoi()
 End Sub
 Public Sub sua(ByVal dto As GIAOVIENTHEDto)
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update GIAOVIENTHE Set IDGIAOVIEN=? ,IDLOPHOC=? ,NGAY=? ,TRANGTHAI=? ,GHICHU= ? where IDGIAOVIENTHE= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
cmd.Parameters.Add("@IDGIAOVIEN", OleDbType.Integer)
cmd.Parameters.Add("@IDLOPHOC", OleDbType.Integer)
cmd.Parameters.Add("@NGAY", OleDbType.Date)
cmd.Parameters.Add("@TRANGTHAI", OleDbType.Integer)
cmd.Parameters.Add("@GHICHU", OleDbType.VarWChar)
cmd.Parameters.Add("@IDGIAOVIENTHE", OleDbType.Integer)
cmd.Parameters("@IDGIAOVIEN").Value = dto.IDGIAOVIEN
cmd.Parameters("@IDLOPHOC").Value = dto.IDLOPHOC
cmd.Parameters("@NGAY").Value = dto.NGAY
cmd.Parameters("@TRANGTHAI").Value = dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = dto.GHICHU
cmd.Parameters("@IDGIAOVIENTHE").Value = dto.IDGIAOVIENTHE
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update GIAOVIENTHE Set IDGIAOVIEN= @IDGIAOVIEN , IDLOPHOC= @IDLOPHOC , NGAY= @NGAY , TRANGTHAI= @TRANGTHAI , GHICHU= @GHICHU where IDGIAOVIENTHE= @IDGIAOVIENTHE"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
cmd.Parameters.Add("@IDGIAOVIEN", SqlDbType.Int)
cmd.Parameters.Add("@IDLOPHOC", SqlDbType.Int)
cmd.Parameters.Add("@NGAY", SqlDbType.DateTime)
cmd.Parameters.Add("@TRANGTHAI", SqlDbType.Int)
cmd.Parameters.Add("@GHICHU", SqlDbType.NVarChar)
cmd.Parameters.Add("@IDGIAOVIENTHE", SqlDbType.Int)
cmd.Parameters("@IDGIAOVIEN").Value = dto.IDGIAOVIEN
cmd.Parameters("@IDLOPHOC").Value = dto.IDLOPHOC
cmd.Parameters("@NGAY").Value = dto.NGAY
cmd.Parameters("@TRANGTHAI").Value = dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = dto.GHICHU
cmd.Parameters("@IDGIAOVIENTHE").Value = dto.IDGIAOVIENTHE
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update GIAOVIENTHE Set IDGIAOVIEN= @IDGIAOVIEN , IDLOPHOC= @IDLOPHOC , NGAY= @NGAY , TRANGTHAI= @TRANGTHAI , GHICHU= @GHICHU where IDGIAOVIENTHE= @IDGIAOVIENTHE"
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
cmd.Parameters("@IDGIAOVIEN").Value = dto.IDGIAOVIEN
cmd.Parameters("@IDLOPHOC").Value = dto.IDLOPHOC
cmd.Parameters("@NGAY").Value = dto.NGAY
cmd.Parameters("@TRANGTHAI").Value = dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = dto.GHICHU
cmd.Parameters("@IDGIAOVIENTHE").Value = dto.IDGIAOVIENTHE
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update GIAOVIENTHE Set IDGIAOVIEN= @IDGIAOVIEN , IDLOPHOC= @IDLOPHOC , NGAY= @NGAY , TRANGTHAI= @TRANGTHAI , GHICHU= @GHICHU where IDGIAOVIENTHE= @IDGIAOVIENTHE"
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
cmd.Parameters("@IDGIAOVIEN").Value = dto.IDGIAOVIEN
cmd.Parameters("@IDLOPHOC").Value = dto.IDLOPHOC
cmd.Parameters("@NGAY").Value = dto.NGAY
cmd.Parameters("@TRANGTHAI").Value = dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = dto.GHICHU
cmd.Parameters("@IDGIAOVIENTHE").Value = dto.IDGIAOVIENTHE
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update GIAOVIENTHE Set IDGIAOVIEN= @IDGIAOVIEN , IDLOPHOC= @IDLOPHOC , NGAY= @NGAY , TRANGTHAI= @TRANGTHAI , GHICHU= @GHICHU where IDGIAOVIENTHE= @IDGIAOVIENTHE"
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
cmd.Parameters.Add("@IDGIAOVIEN", MySqlDbType.Int32)
cmd.Parameters.Add("@IDLOPHOC", MySqlDbType.Int32)
cmd.Parameters.Add("@NGAY",  MySqlDbType.DateTime)
cmd.Parameters.Add("@TRANGTHAI", MySqlDbType.Int32)
cmd.Parameters.Add("@GHICHU", MySqlDbType.String)
cmd.Parameters.Add("@IDGIAOVIENTHE", MySqlDbType.Int32)
cmd.Parameters("@IDGIAOVIEN").Value = dto.IDGIAOVIEN
cmd.Parameters("@IDLOPHOC").Value = dto.IDLOPHOC
cmd.Parameters("@NGAY").Value = dto.NGAY
cmd.Parameters("@TRANGTHAI").Value = dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = dto.GHICHU
cmd.Parameters("@IDGIAOVIENTHE").Value = dto.IDGIAOVIENTHE
 cmd.ExecuteNonQuery()
 End Select
 Ngatketnoi()
 End Sub
 Public Sub SuaIDGIAOVIEN( ByVal IDGIAOVIEN as System.Int32, ByVal IDGIAOVIENTHE As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update GIAOVIENTHE Set IDGIAOVIEN = ?  where IDGIAOVIENTHE= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@IDGIAOVIEN", OleDbType.Integer)
 cmd.Parameters.Add("@IDGIAOVIENTHE", OleDbType.Integer)
 cmd.Parameters("@IDGIAOVIEN").Value =  IDGIAOVIEN
cmd.Parameters("@IDGIAOVIENTHE").Value =  IDGIAOVIENTHE
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update GIAOVIENTHE Set IDGIAOVIEN = @IDGIAOVIEN  where IDGIAOVIENTHE= @IDGIAOVIENTHE"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@IDGIAOVIEN", SqlDbType.Int)
 cmd.Parameters.Add("@IDGIAOVIENTHE", SqlDbType.Int)
 cmd.Parameters("@IDGIAOVIEN").Value =  IDGIAOVIEN
cmd.Parameters("@IDGIAOVIENTHE").Value =  IDGIAOVIENTHE
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update GIAOVIENTHE Set IDGIAOVIEN =" & IDGIAOVIEN & "  where IDGIAOVIENTHE=" & IDGIAOVIENTHE & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update GIAOVIENTHE Set IDGIAOVIEN =" & IDGIAOVIEN & "  where IDGIAOVIENTHE=" & IDGIAOVIENTHE & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update GIAOVIENTHE Set IDGIAOVIEN =" & IDGIAOVIEN & "  where IDGIAOVIENTHE=" & IDGIAOVIENTHE & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaIDLOPHOC( ByVal IDLOPHOC as System.Int32, ByVal IDGIAOVIENTHE As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update GIAOVIENTHE Set IDLOPHOC = ?  where IDGIAOVIENTHE= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@IDLOPHOC", OleDbType.Integer)
 cmd.Parameters.Add("@IDGIAOVIENTHE", OleDbType.Integer)
 cmd.Parameters("@IDLOPHOC").Value =  IDLOPHOC
cmd.Parameters("@IDGIAOVIENTHE").Value =  IDGIAOVIENTHE
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update GIAOVIENTHE Set IDLOPHOC = @IDLOPHOC  where IDGIAOVIENTHE= @IDGIAOVIENTHE"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@IDLOPHOC", SqlDbType.Int)
 cmd.Parameters.Add("@IDGIAOVIENTHE", SqlDbType.Int)
 cmd.Parameters("@IDLOPHOC").Value =  IDLOPHOC
cmd.Parameters("@IDGIAOVIENTHE").Value =  IDGIAOVIENTHE
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update GIAOVIENTHE Set IDLOPHOC =" & IDLOPHOC & "  where IDGIAOVIENTHE=" & IDGIAOVIENTHE & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update GIAOVIENTHE Set IDLOPHOC =" & IDLOPHOC & "  where IDGIAOVIENTHE=" & IDGIAOVIENTHE & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update GIAOVIENTHE Set IDLOPHOC =" & IDLOPHOC & "  where IDGIAOVIENTHE=" & IDGIAOVIENTHE & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaNGAY( ByVal NGAY as System.DateTime, ByVal IDGIAOVIENTHE As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update GIAOVIENTHE Set NGAY = ?  where IDGIAOVIENTHE= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@NGAY", OleDbType.Date)
 cmd.Parameters.Add("@IDGIAOVIENTHE", OleDbType.Integer)
 cmd.Parameters("@NGAY").Value =  NGAY
cmd.Parameters("@IDGIAOVIENTHE").Value =  IDGIAOVIENTHE
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update GIAOVIENTHE Set NGAY = @NGAY  where IDGIAOVIENTHE= @IDGIAOVIENTHE"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@NGAY", SqlDbType.DateTime)
 cmd.Parameters.Add("@IDGIAOVIENTHE", SqlDbType.Int)
 cmd.Parameters("@NGAY").Value =  NGAY
cmd.Parameters("@IDGIAOVIENTHE").Value =  IDGIAOVIENTHE
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update GIAOVIENTHE Set NGAY =" & NGAY & "  where IDGIAOVIENTHE=" & IDGIAOVIENTHE & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update GIAOVIENTHE Set NGAY =" & NGAY & "  where IDGIAOVIENTHE=" & IDGIAOVIENTHE & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update GIAOVIENTHE Set NGAY =" & NGAY & "  where IDGIAOVIENTHE=" & IDGIAOVIENTHE & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaTRANGTHAI( ByVal TRANGTHAI as System.Int32, ByVal IDGIAOVIENTHE As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update GIAOVIENTHE Set TRANGTHAI = ?  where IDGIAOVIENTHE= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@TRANGTHAI", OleDbType.Integer)
 cmd.Parameters.Add("@IDGIAOVIENTHE", OleDbType.Integer)
 cmd.Parameters("@TRANGTHAI").Value =  TRANGTHAI
cmd.Parameters("@IDGIAOVIENTHE").Value =  IDGIAOVIENTHE
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update GIAOVIENTHE Set TRANGTHAI = @TRANGTHAI  where IDGIAOVIENTHE= @IDGIAOVIENTHE"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@TRANGTHAI", SqlDbType.Int)
 cmd.Parameters.Add("@IDGIAOVIENTHE", SqlDbType.Int)
 cmd.Parameters("@TRANGTHAI").Value =  TRANGTHAI
cmd.Parameters("@IDGIAOVIENTHE").Value =  IDGIAOVIENTHE
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update GIAOVIENTHE Set TRANGTHAI =" & TRANGTHAI & "  where IDGIAOVIENTHE=" & IDGIAOVIENTHE & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update GIAOVIENTHE Set TRANGTHAI =" & TRANGTHAI & "  where IDGIAOVIENTHE=" & IDGIAOVIENTHE & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update GIAOVIENTHE Set TRANGTHAI =" & TRANGTHAI & "  where IDGIAOVIENTHE=" & IDGIAOVIENTHE & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaGHICHU( ByVal GHICHU as System.String, ByVal IDGIAOVIENTHE As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update GIAOVIENTHE Set GHICHU = ?  where IDGIAOVIENTHE= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@GHICHU", OleDbType.VarWChar)
 cmd.Parameters.Add("@IDGIAOVIENTHE", OleDbType.Integer)
 cmd.Parameters("@GHICHU").Value =  GHICHU
cmd.Parameters("@IDGIAOVIENTHE").Value =  IDGIAOVIENTHE
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update GIAOVIENTHE Set GHICHU = @GHICHU  where IDGIAOVIENTHE= @IDGIAOVIENTHE"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@GHICHU", SqlDbType.NVarChar)
 cmd.Parameters.Add("@IDGIAOVIENTHE", SqlDbType.Int)
 cmd.Parameters("@GHICHU").Value =  GHICHU
cmd.Parameters("@IDGIAOVIENTHE").Value =  IDGIAOVIENTHE
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update GIAOVIENTHE Set GHICHU =" & GHICHU & "  where IDGIAOVIENTHE=" & IDGIAOVIENTHE & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update GIAOVIENTHE Set GHICHU =" & GHICHU & "  where IDGIAOVIENTHE=" & IDGIAOVIENTHE & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update GIAOVIENTHE Set GHICHU =" & GHICHU & "  where IDGIAOVIENTHE=" & IDGIAOVIENTHE & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub layBang()
 Chuoi_SQL = " Select * from GIAOVIENTHE
 Doc_bang()
 End Sub
 Public Sub layBangTheoIDGIAOVIENTHE(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "IDGIAOVIENTHE=" & ARRAY1.Item(i) & ""
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from GIAOVIENTHE" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoIDGIAOVIENTHE(ByVal IDGIAOVIENTHE As System.Int32 )
 Chuoi_SQL = " Select * from GIAOVIENTHE where  IDGIAOVIENTHE = " & IDGIAOVIENTHE & ""
 Doc_bang()
 End Sub
 Public Sub XOABangTheoIDGIAOVIENTHE(ByVal IDGIAOVIENTHE As System.Int32)
 Dim strsql As String
 strSQL = "Delete From GIAOVIENTHE Where IDGIAOVIENTHE=" & IDGIAOVIENTHE & ""
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoIDGIAOVIEN(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "IDGIAOVIEN=" & ARRAY1.Item(i) & ""
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from GIAOVIENTHE" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoIDGIAOVIEN(ByVal IDGIAOVIEN As System.Int32 )
 Chuoi_SQL = " Select * from GIAOVIENTHE where  IDGIAOVIEN = " & IDGIAOVIEN & ""
 Doc_bang()
 End Sub
 Public Sub XOABangTheoIDGIAOVIEN(ByVal IDGIAOVIEN As System.Int32)
 Dim strsql As String
 strSQL = "Delete From GIAOVIENTHE Where IDGIAOVIEN=" & IDGIAOVIEN & ""
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoIDLOPHOC(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "IDLOPHOC=" & ARRAY1.Item(i) & ""
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from GIAOVIENTHE" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoIDLOPHOC(ByVal IDLOPHOC As System.Int32 )
 Chuoi_SQL = " Select * from GIAOVIENTHE where  IDLOPHOC = " & IDLOPHOC & ""
 Doc_bang()
 End Sub
 Public Sub XOABangTheoIDLOPHOC(ByVal IDLOPHOC As System.Int32)
 Dim strsql As String
 strSQL = "Delete From GIAOVIENTHE Where IDLOPHOC=" & IDLOPHOC & ""
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoNGAY(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "NGAY='" & ARRAY1.Item(i) & "'"
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from GIAOVIENTHE" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoNGAY(ByVal NGAY As System.DateTime )
 Chuoi_SQL = " Select * from GIAOVIENTHE where  NGAY = @Ngay
 Doc_bang_Dk_ngay(NGAY)
 End Sub
 Public Sub layBangTheoNGAY(ByVal NGAY1 As System.DateTime,ByVal NGAY2 As System.DateTime )
 Chuoi_SQL = " Select * from GIAOVIENTHE where  NGAY >= @Ngay and NGAY <= @denNgay ORDER BY NGAY
 Doc_bang_Dk_ngay(NGAY1,NGAY2)
 End Sub
 Public Sub XOABangTheoNGAY(ByVal NGAY As System.DateTime)
 Dim strsql As String
 strSQL = "Delete From GIAOVIENTHE Where NGAY='" & NGAY & "'"
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoTRANGTHAI(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "TRANGTHAI=" & ARRAY1.Item(i) & ""
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from GIAOVIENTHE" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoTRANGTHAI(ByVal TRANGTHAI As System.Int32 )
 Chuoi_SQL = " Select * from GIAOVIENTHE where  TRANGTHAI = " & TRANGTHAI & ""
 Doc_bang()
 End Sub
 Public Sub XOABangTheoTRANGTHAI(ByVal TRANGTHAI As System.Int32)
 Dim strsql As String
 strSQL = "Delete From GIAOVIENTHE Where TRANGTHAI=" & TRANGTHAI & ""
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoGHICHU(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "GHICHU='" & ARRAY1.Item(i) & "'"
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from GIAOVIENTHE" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoGHICHU_like (ByVal GHICHU As System.String )
 Chuoi_SQL = " Select * from GIAOVIENTHE where  GHICHU  like '%" & GHICHU & "%'"
 Doc_bang()
 End Sub
 Public Sub layBangTheoGHICHU(ByVal GHICHU As System.String )
 Chuoi_SQL = " Select * from GIAOVIENTHE where  GHICHU = '" & GHICHU & "'"
 Doc_bang()
 End Sub
 Public Sub XOABangTheoGHICHU(ByVal GHICHU As System.String)
 Dim strsql As String
 strSQL = "Delete From GIAOVIENTHE Where GHICHU='" & GHICHU & "'"
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangNhieuTable
 Chuoi_SQL = " Select IDGIAOVIENTHE ,IDGIAOVIEN ,IDLOPHOC ,NGAY ,TRANGTHAI ,GHICHU  from GIAOVIENTHE"
 Doc_bang()
 End sub
Public Sub TaoTable()
Dim strsql As String
strsql = ""
Select Case ketnoi.MsSql
Case Class_KieuDL.Access 
Case Class_KieuDL.Sql, Class_KieuDL.sqlExpress
strsql = ""
Case Class_KieuDL.SqlCe
strsql = ""
Case Class_KieuDL.Oracle
strsql = ""
Case else 
strsql = ""
End Select
Thuc_hien_lenh(strsql)
End Sub
 End Class

